package previous.Test_0305;

import java.util.Scanner;

/**
 * Created with Intellij IDEA
 * Description:
 * User: 星辰
 */
public class Blue_bridge {
    //统计子矩阵
    public static void main1(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int n=scan.nextInt();
        int m=scan.nextInt();
        int k=scan.nextInt();
        long count=0;
        int[][] a=new int[n][m];
        int[][] dp=new int[n+1][m+1];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                a[i][j]=scan.nextInt();
            }
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                dp[i][j]=dp[i][j-1]+dp[i-1][j]+a[i-1][j-1]-dp[i-1][j-1];
            }
        }
        for (int x1 = 1; x1 <= n; x1++) {
            for (int y1 = 1; y1 <= m; y1++) {
                for (int x2 = x1; x2 <= n; x2++) {
                    for (int y2 = y1; y2 <= m; y2++) {
                        // 计算子矩阵和
                        long sum = dp[x2][y2] - dp[x1 - 1][y2] - dp[x2][y1 - 1] + dp[x1 - 1][y1 - 1];
                        if (sum <= k) {
                            count++;
                        }
                    }
                }
            }
        }
        System.out.println(count);
        scan.close();
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int n=scan.nextInt();
        int m=scan.nextInt();
        int k=scan.nextInt();
        long count=0;
        int[][] a=new int[n][m];
        int[][] dp=new int[n+1][m+1];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                a[i][j]=scan.nextInt();
            }
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                dp[i][j]=dp[i][j-1]+dp[i-1][j]+a[i-1][j-1]-dp[i-1][j-1];
            }
        }
        //枚举上下行
        for (int x1 = 1; x1 <= n; x1++) {
            for (int x2 = x1; x2 <= n; x2++) {
                int left=1;
                for (int right = 1; right <=m ; right++) {
                    while(left<=right && getSum(dp,x1,left,x2,right)>k){
                        left++;
                    }
                    count+=right-left+1;
                }
            }
        }
        System.out.println(count);
        scan.close();
    }
    public static long getSum(int[][] dp,int x1,int y1,int x2,int y2){
        return dp[x2][y2] - dp[x1 - 1][y2] - dp[x2][y1 - 1] + dp[x1 - 1][y1 - 1];
    }
}
